package controller.common;

import base.response.Select2;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import qiyeku.orm.entity.CompanyPool;
import qiyeku.services.CompanyPoolServices;

import java.util.List;

/**
 * 功能:
 * 作者: 洪世成
 * 日期: 2017/9/9
 * 版权所有: admin
 */
@Controller
@RequestMapping("common/companyPool")
public class CompanyPoolController extends BaseController {

    @Autowired
    CompanyPoolServices companyPoolServices;

    @ResponseBody
    @RequestMapping(value = {"getCompanyByNameLike"})
    public Select2 addManagerAssess(@RequestParam(defaultValue = "") String q, @RequestParam(defaultValue = "1")  Integer page) {

        Select2 select2 =new Select2();
        PageHelper.startPage(page,30);
        List<CompanyPool>    companyPools=   companyPoolServices.selectByNameLike(q);
        for (int i   = 0;i  <companyPools.size() ; i++) {
            select2.putItem(companyPools.get(i).getUnitName(),companyPools.get(i).getUnitName(),companyPools.get(i).getUnitCode());
        }
        select2.setTotal_count(((Page<CompanyPool>) companyPools).getTotal());
        return  select2;
    }


    

   

   
}





